﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - 黃石簡易平台</title>
    <link rel="stylesheet" href="~/Content/common.css" />
    <link rel="stylesheet" href="~/Content/iconfont.css" />
    <link rel="stylesheet" href="~/Content/jquery.dropdown_select.css" />
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/jquery.dropdown.js"></script>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    <style>
        .userpicdiv {
            width: 50px;
            height: 50px;
            text-align: center;
            position: absolute;
            right: 165px;
            top: 15px;
        }

            .userpicdiv ul {
                padding: 0;
                margin: 0;
                font-size: 14px;
                font-weight: 100;
                list-style: none;
                text-decoration: none;
                background-color: #222222;
                color: white;
                width: 150px;
                text-align: center;
                border: 0px solid black;
                border-radius: 5px;
                float: left;
            }

        .userpic {
            border-radius: 40px;
            margin: auto;
            width: 30px;
            height: 30px;
        }

        .userinfo {
        }

            .userinfo:hover .setinfo {
                display: block;
                clear: both;
            }

        .setinfo {
            display: none;
        }

            .setinfo li {
                height: 30px;
                line-height: 30px;
            }

                .setinfo li:hover {
                    cursor: pointer;
                    background-color: dimgrey;
                    border-radius: 5px;
                }

        .pageinfodiv {
            margin-left: 0%;
            color: white;
            width: 120px;
            height: 50px;
            text-align: center;
            line-height: 50px;
            border-radius: 5px;
            position: absolute;
            top: 0px;
            left: 10%;
        }

            .pageinfodiv ul {
                padding: 0;
                margin: 0;
                font-size: 14px;
                font-weight: 100;
                list-style: none;
                text-decoration: none;
                background-color: #222222;
                color: white;
                width: 150px;
                text-align: center;
                border: 0px solid black;
                border-radius: 5px;
                float: left;
            }

        .pageinfo {
        }

            .pageinfo:hover .pagedetail {
                display: block;
                clear: both;
            }

        .pagedetail {
            display: none;
        }

            .pagedetail li {
                height: 30px;
                line-height: 30px;
            }

                .pagedetail li:hover {
                    cursor: pointer;
                    background-color: dimgrey;
                    border-radius: 5px;
                }

        #loading-mask {
            position: fixed;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.2);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10000;
        }

        .loading-content {
            color: white;
            font-size: 16px;
        }
    </style>
</head>
<body>
    @***********遮罩層***********@
    <div id="loading-mask" style="display: none;">
        <div class="loading-content">
            @*正在加載中...*@
            <img src="~/Pictrue/加載中2.gif" width="60" height="60" />
        </div>
    </div>
    @***********遮罩層***********@
    @{   
        string t_color = "#222222";
        if (ViewBag.PageDesc == "KPI")
        {
            t_color = "#507cd1";
        }

    }
    <div class="navbar navbar-inverse navbar-fixed-top" style="background-color:@t_color">
        <div class="container" style="width: 80%; background-color: @t_color">
            <div class="navbar-header" style="background-color:@t_color">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @*<img src="~/Pictrue/EMCHS.png" style="margin: 12px auto auto 10px;" />*@
                <div style="width:150px;height:50px;"></div>
            </div>
            <div class="pageinfodiv">
                <ul class="pageinfo" style="background-color:@t_color">
                    <li style="height: 50px; cursor: pointer;" onclick="currpage()">@ViewBag.PageDesc</li>
                    @{
                        <li>
                            <ul class="pagedetail" style="background-color:@t_color">
                                @{
                                    foreach (System.Data.DataRow item in ViewBag.PageL2)
                                    {
                                        <li onclick="jumppage('@item["PAGE_URL2"].ToString().Split('/')[1]')">@item["PAGE_NAME"].ToString()</li>
                                    }
                                }
                            </ul>
                        </li>
                        @*if (@ViewBag.PageDesc == "KPI")
            {
                <li>
                    <ul class="pagedetail">
                        <li onclick="jumppage('/Kpi/KpiItem')">基礎數據</li>
                        <li onclick="jumppage('/Kpi/KpiMain')">KPI目標</li>
                        <li onclick="jumppage('/Kpi/KpiAct')">KPI實際</li>
                        <li onclick="jumppage('/Kpi/KpiActSource')">分子/分母來源</li>
                    </ul>
                </li>
            }*@
                    }
                </ul>
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav" style="background-color:@t_color">
                    @{
                        foreach (System.Data.DataRow item in ViewBag.Page)
                        {
                            <li>@Html.ActionLink(item["PAGE_NAME"].ToString(), item["PAGE_URL2"].ToString().Split('/')[1], item["PAGE_URL2"].ToString().Split('/')[0])</li>
                        }
                    }
                </ul>
            </div>
            <div class="userpicdiv">
                <ul class="userinfo" style="background-color:@t_color">
                    @*<li><img class="userpic" src="~/Pictrue/USER.jpg" /></li>*@
                    <li style="height: 35px; cursor: pointer;">當前用戶：@Session["Name"].ToString()</li>
                    <li>
                        <ul class="setinfo" style="background-color:@t_color">
                            <li id="setpage" onclick="setpage()">設為主頁</li>
                            @*<li id="updpwd" onclick="jumppage('/Login/UpdatePwd')">修改密碼</li>*@
                            <li id="loginout" onclick="logout()">退出登錄</li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div>
        @RenderBody()
        @*<hr />
            <footer>
                <p>&copy; @DateTime.Now.Year - EMCHS</p>
            </footer>*@
    </div>

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

<script>
    function setpage() {
        $.ajax({
            type: "post",
            url: "/Login/SetPage",
            data: {
                pageinfo: "@ViewBag.PageInfo"
            },
            success: function (data) {
                var result = JSON.parse(data);
                if (result.flag) {
                    alert(result.msg);
                }
            },
            error: function (err) {

            }
        });
    }
    function currpage() {
        window.location.reload();
    }
    function jumppage(url) {
        window.location.href = url;
    }
    function logout() {
        $.ajax({
            type: "post",
            url: "/Login/Logout",
            data: { },
            success: function (data) {
                window.location.href = "/Login/Login";
            },
            error: function (err) {

            }
        });
    }
    // 显示遮罩
    function showLoading() {
        document.getElementById('loading-mask').style.display = 'flex';
    }
    // 隐藏遮罩
    function hideLoading() {
        document.getElementById('loading-mask').style.display = 'none';
    }
    function encodeddata(message) {
        var in_str = btoa(message);
        const data = { in_str: in_str };
        const encoded = encodeURIComponent(JSON.stringify(data));
        return encoded;
    }
</script>